package com.artisan.domain.repositoryInterface;

import com.artisan.domain.entity.MAd;
import com.artisan.domain.info.AdInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * 广告数据访问接口
 */
@Repository
public interface IAdRepository extends JpaRepository<MAd, Integer> {
    @Query(value = "select c from MAd c " +
            "left join MAdPosition ap on c.adPositionId=ap.id" +
            " where c.name=:name order by c.addDate desc ")
    Page<AdInfo> find(@Param("name") String name, Pageable pageable);
}
